{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('''千寻你好，人们叫我'无脸男'\n",
    "这个世界的人都选择无视我\n",
    "只有你看到了我并和我打招呼\n",
    "我感到很孤单，很孤单\n",
    "你愿意和我成为朋友吗？''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"千寻你好，人们叫我'无脸男'\\n这个世界的人都选择无视我\\n只有你看到了我并和我打招呼\\n我感到很孤单，很孤单\\n你愿意和我成为朋友吗？\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "slogan = '脸黑怪我咯'\n",
    "number = '7.8'\n",
    "unit = '张'\n",
    "sentence = '蓝票一个SSR都没有'\n",
    "print(slogan+str(int(float(number)))+unit+sentence)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "number1 = 1\n",
    "number2 = 2\n",
    "unit1 = '人'\n",
    "unit2 = '眼'\n",
    "line1 = '我编程累'\n",
    "line2 = '是bug相随'\n",
    "sentence1 = '碎掉的节操满地堆'\n",
    "sentence2 = '我只求今日能早归'\n",
    "print(str(number1)+unit1+line1+sentence1+'\\n' \n",
    "    +str(number2)+unit2+line2+sentence2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "choclate = input('罗恩吃了几块巧克力：')  #最好在该位置就强制转换\n",
    "if int(choclate) > 10:\n",
    "    print('罗恩给哈利100块钱')\n",
    "else:\n",
    "    print('哈利给罗恩100块钱')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "time.sleep(1)\n",
    "ans1 = input('您好，欢迎古灵阁，请问您需要帮助吗？需要or不需要？')\n",
    "if ans1 == '需要':\n",
    "    time.sleep(1)\n",
    "    ans2 = int(input('请问您需要什么帮助呢？1 存取款；2 货币兑换；3 咨询'))\n",
    "    if ans2 == 1 :\n",
    "        time.sleep(1)\n",
    "        print('去存取款窗')\n",
    "    elif ans2 == 2:\n",
    "        print('金加隆和人民币的兑换率为1:51.3，即一金加隆=51.3人民币')\n",
    "        time.sleep(1)\n",
    "        money = float(input('请问您需要兑换多少金加隆呢？'))\n",
    "        time.sleep(1)\n",
    "        print('好的，我知道了，您需要兑换'+str(money)+'金加隆。')\n",
    "        time.sleep(1)\n",
    "        print('那么，您需要付给我'+str(money*51.3)+'人民币。')\n",
    "    elif ans2 == 3:\n",
    "        time.sleep(1)\n",
    "        print('去咨询窗口')\n",
    "else :\n",
    "    time.sleep(1)\n",
    "    print('好的，再见。')\n",
    "\n",
    "    ##  问题1：您好，欢迎古灵阁，请问您需要帮助吗？需要or不需要？ 需要\n",
    "    ##  请问您需要什么帮助呢？1 存取款；2 货币兑换；3 咨询 1   缺少int（）\n",
    "    ##  问题2：NameError: name 'ans2' is not defined      if嵌套"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### 格式化字符串 ('%d' % () )   和   ( '{}'.format() )  两种方法\n",
    "blood,attack = 100,50\n",
    "print('【玩家】\\n'+'血量：'+str(100)+'\\n攻击：'+str(50)) \n",
    "print('【玩家】\\n血量：%s \\n攻击：%s'%(100,50)) #%后面有一个字母s，这是一个类型码，用来控制数据显示的类型。%s(占位符)就表示先占一个字符串类型的位置。\n",
    "print('【玩家】\\n血量：%d \\n攻击：%d'%(blood,attack))\n",
    "print('【玩家】\\n血量：{0:d} \\n攻击：{1:5.2f}'.format(100,attack))  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "['Blowing', 'in', 'the', 'wind'] \n Blowing,in,the,wind \n Blowing   in  the    wind  \n 7 \n b'Blowing,  in, the  , wind ' \n Blowing,  in, the  , wind  \n True \n -1 \n 7\n"
     ]
    }
   ],
   "source": [
    "# 字符串的常用方法(非常之多)\n",
    "song = 'Blowing,  in, the  , wind '\n",
    "lis = [x.strip() for x in song.split(',')]   # 字符串截断,并去除空格\n",
    "code = song.encode('gbk')       # 字符串编码\n",
    "print(\n",
    "    lis,'\\n',           \n",
    "    ','.join(lis),'\\n',         # 用','合并字符串\n",
    "    song.replace(',',' '),'\\n', # 替换字符串内容\n",
    "    song.count(' '),'\\n',       # 字符串出现次数\n",
    "\n",
    "    code,'\\n',\n",
    "    code.decode(),'\\n',\n",
    "\n",
    "    'in' in song,'\\n',\n",
    "    song.find('.'),'\\n',      # 没找到字符串时返回-1\n",
    "    song.index(',')           # 没找到字符串时返回异常\n",
    ")"
   ]
  },
  {
   "source": [
    "转义字符表\n",
    "![转义字符](https://bkimg.cdn.bcebos.com/pic/3bf33a87e950352ab1edf5555043fbf2b3118bdb?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2U4MA==,g_7,xp_5,yp_5/format,f_auto)"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.4 64-bit ('base': conda)"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "interpreter": {
   "hash": "2a7e95a32014fc1ccf24626d45a98c6e7b4373277259c22f47a91d487fc3e8a5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}